const App = {
    data() {
        return {
            nodeKey:'',
            colunmData:[],
            tableData: [],
            form:{
                Page:1,
                Limit:100,
                Condition:'',
            },
            Total:0,
            loading:false
        }
    },
    mounted() {
        let ls_URL = window.location.href;
        this.nodeKey = getQueryObject(ls_URL, "nodeKey");// 获取 nodeKey 参数
        this.getColumn();
    },
    computed:{
        JsonString() {
            return function (str) {
                const isArrayOrObject = (value) => value !== null && typeof value === 'object';
                if (isArrayOrObject(str)) {
                    try {
                        return JSON.stringify(str);
                    } catch (e) {}
                }
                return str;
            }
        }
    },
    methods: {
        handleSizeChange(newSize) {
            this.form.Page = 1;
            this.form.Limit = newSize;
            this.getList(this.form);
        },
        handleCurrentChange(newPage) {
            this.form.Page = newPage;
            this.getList(this.form);
        },
        getColumn(){
            this.loading = true;
            $.ajax({
                headers: {
                    "content-type": "application/x-www-form-urlencoded",
                    "Session":'session5'
                },
                url: `${y}/generalQueryAllColumnByTableName`,
                method: "get",
                data:{
                    TableName:this.nodeKey
                },
                success: (res) => {
                    if (res.Status == 'success') {
                        this.colunmData = res.Data;
                        this.getList(this.form);
                    }
                },
            });
        },
        getList(data) {
            this.loading = true;
            $.ajax({
                headers: {
                    "content-type": "application/x-www-form-urlencoded",
                    "Session":'session5'
                },
                url: `${y}/generalPaginationQueryByTableName`,
                method: "post",
                data:{
                    TableName:this.nodeKey,
                    ...data
                },
                success: (res) => {
                    if (res.Status == 'success') {
                        this.tableData = res.Data;
                        this.Total = res.Total
                    }
                },
                complete: () =>{
                    this.loading = false;
                }
            });
        },
        goBack() {
            window.history.back();
        },
        reset() {
            window.location.reload();
        },
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus,{locale: zhCn});
app.mount("#app");
